<title>Thông Tin Sản Phẩm Theo Người Xếp - Origami Shop | Origamishop.net</title>
<?php
	$rowsPerPage = 10; 	
	$pageNum = 1; 	
	if(isset($_GET['page']))
	{
		$pageNum = $_GET['page'];
	}
	$offset = ($pageNum - 1) * $rowsPerPage;
	if (isset($_REQUEST["ld_id"]) == false)
	{
		header("location:index.php");
	}
	$id = $_REQUEST["ld_id"];
	$strSQL = "SELECT * FROM sp Inner Join ld ON ld.ld_nick = sp.sp_ld 
	where ld_id = $id LIMIT ".$offset.",".$rowsPerPage;
	$result3 = DataProvider::ExecuteQuery($strSQL);
	while($sp = mysql_fetch_array($result3))
	{
		echo '
        <div id="ld">
            <div class="ld7x">
            <div class="ld3x5"></div>
            <div class="ldfull"></div>
            </div>
            <div class="ld1"></div>
            <div class="ld45x">
            	<div class="ld10x"><a href="'.$host["l_link"].'home.php?typ=product&act=detail&sp_id='.$sp["sp_id"].'"><img src="'.$sp["sp_t1"].'" width="96px" height="100px" border="0" quality="50"/></a></div>
				<div class="ld1"></div>
				<div class="ld4"></div>
                <div class="ldmain">
					<div class="ldmain10x2"></div>
					<div class="ld100"><strong>Tên Sản Phẩm:</strong> <a href="'.$host["l_link"].'home.php?typ=product&act=detail&sp_id='.$sp["sp_id"].'">'.$sp["sp_ten"].'</a> ('.$sp["sp_tenjp"].')</div>
					<div class="ld50"><strong>Giá sản phẩm:</strong> '.$sp["sp_gia"].'đ</div>
					<div class="ld50"><strong>Giảm Giá:</strong> '.$sp["sp_sall"].'đ</div>
					<div class="ld50"><strong>Thời Gian Xếp:</strong> '.$sp["sp_time"].'</div>
					<div class="ld50"><strong>Người Xếp:</strong> <a href="'.$host["l_link"].'home.php?typ=product&act=viewld&ld_id='.$sp["ld_id"].'">'.$sp["ld_ten"].'</a></div>
					<div class="ld100"><strong>Kích Thước Mẫu:</strong> '.$sp["sp_size"].'</div>
					<div class="ld50"><strong>Lượng Tồn:</strong> '.$sp["sp_ton"].'</div>
					<div class="ld50"><strong>Lượt Bán:</strong> '.$sp["sp_count"].'</div>
					<div class="ld50"><strong>Lượt Xem:</strong> '.$sp["sp_see"].'</div>
				</div>
            </div>
            <div class="ld1"></div>
			<div class="ld5x">
				<div class="ld3x5"></div>
				<div class="ldfull">
			';
		if($_SESSION["IsLogin"] == true)
		   {
			echo '<a href="home.php?typ=product&act=addcart&sp_id='.$sp["sp_id"].'" title="Thêm Vào Giỏ Hàng">';
		   }
		   else 
			{
			echo '<a href="home.php?typ=user&act=login">';
			}
			echo '
				<img class="add" src="'.$div["md_sty"].'cartadd.png" border="0" quality="100"/></a>
				</div>
			</div>
        </div>
		<div class="divspla"></div>
		<div class="divspdi"></div>
		<div class="divspla"></div>
		';
	}
	$strSQL = "SELECT COUNT(*) AS numrows from sp Inner Join ld ON ld.ld_nick = sp.sp_ld where ld_id = $id";
	$result = DataProvider::executeQuery($strSQL);
	
	$row     = mysql_fetch_array($result, MYSQL_ASSOC);
	$numrows = $row['numrows']; 
	$maxPage = ceil($numrows/$rowsPerPage);
	$self = $_SERVER['PHP_SELF']; 
	$nav  = '';
	for($page = 1; $page <= $maxPage; $page++)
	{
	   if ($page == $pageNum)
	   {
		  $nav .= " $page ";
	   }
	   else
	   {
		  $nav .= " <a href=\"$self?typ=product&act=viewld&ld_id=$id&page=$page\">$page</a> ";
	   }
	}
	if ($pageNum > 1)
	{
	   $page  = $pageNum - 1;
	   $prev  = " <a href=\"$self?typ=product&act=viewld&ld_id=$id&page=$page\">[Pre.]</a> ";
	   $first = " <a href=\"$self?typ=product&act=viewld&ld_id=$id&page=1\">[Fir.]</a> ";
	}
	else
	{
	   $prev  = '&nbsp;';
	   $first = '&nbsp;';
	}
	if ($pageNum < $maxPage)
	{
	   $page = $pageNum + 1;
	   $next = " <a href=\"$self?typ=product&act=viewld&ld_id=$id&page=$page\"> [Nex.]  </a> ";
	   $last = " <a href=\"$self?typ=product&act=viewld&ld_id=$id&page=$maxPage\">  [End]  </a> ";
	}
	else
	{
	   $next = '&nbsp;';
	   $last = '&nbsp;';
	}
	echo "<div style='width:100%;margin-top:10px;'>Page: ". 
	$first . 
	$prev . 
	$nav . 
	$next . 
	$last . "</div>";
	
?>